home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 33
/
Volume 33 - JOGO DISK .iso
/
Games
/
space_dude.swf
/
scripts
/
frame_41
/
DoAction.as
< prev
Wrap
Text File
|
2007-01-12
|
6KB
|
245 lines
moveLayer.hero.gotoAndStop(1);
levelcomplete._visible = false;
var onground = false;
jumpsetup = false;
moveme = function()
{
var _loc1_ = this;
if(_loc1_.x == undefined)
{
_loc1_.startx = _loc1_.x = _loc1_._x;
_loc1_.starty = _loc1_.y = _loc1_._y;
}
_loc1_.dy += 0.5;
var nexty = Math.ceil(_loc1_.y + _loc1_.dy);
var nextx = _loc1_.x + _loc1_.dx;
onground = false;
if(_loc1_.dy >= 0)
{
if(moveLayer.platforms.hitTest(_loc1_.x + moveLayer._x,nexty + moveLayer._y,true) && !jumpsetup)
{
onground = true;
jumping = false;
var _loc3_ = 0;
var _loc2_ = Math.floor(nexty);
while(moveLayer.platforms.hitTest(_loc1_.x + moveLayer._x,_loc2_ + moveLayer._y,true))
{
_loc3_ = _loc3_ + 1;
_loc2_ -= 2;
}
if(_loc3_ < 10)
{
_loc1_.y = _loc2_;
_loc1_.dy = 0;
}
else
{
_loc1_.x -= _loc1_.dx;
_loc1_.dx = 0;
}
}
else if(_loc1_.dy > 5 && !shooting)
{
_loc1_.gotoAndStop(3);
_loc1_.mc.gotoAndStop(11);
}
}
else if(_loc1_.dy < 0)
{
if(moveLayer.platforms.hitTest(_loc1_.x + moveLayer._x,nexty + moveLayer._y - 40,true))
{
_loc1_.dy = 1;
}
}
if(moveLayer.exit.hitTest(_loc1_.x + moveLayer._x,_loc1_.y + moveLayer._y - 40,true))
{
moveLayer.exit.play();
}
if(_loc1_.dy > 9)
{
_loc1_.dy = 9;
}
if(!jumpsetup)
{
_loc1_.x += _loc1_.dx;
_loc1_.y += _loc1_.dy;
}
if(Key.isDown(39) && !shooting)
{
if(jumping)
{
_loc1_.dx += 0.4;
}
else
{
_loc1_.dx += 1;
}
_loc1_._xscale = 80;
}
else if(Key.isDown(37) && !shooting)
{
if(jumping)
{
_loc1_.dx -= 0.4;
}
else
{
_loc1_.dx -= 1;
}
_loc1_._xscale = -80;
}
else
{
_loc1_.dx *= 0.7;
}
if(_loc1_.dx > 7)
{
_loc1_.dx = 7;
}
if(_loc1_.dx < -7)
{
_loc1_.dx = -7;
}
if(!jumpsetup && !jumping && !shooting && onground)
{
if(Math.abs(_loc1_.dx) < 0.5)
{
_loc1_.dx = 0;
_loc1_.gotoAndStop(1);
}
else
{
_loc1_.gotoAndStop(2);
}
}
if(Key.isDown(38) && _loc1_.dy >= 0 && _loc1_.dy < 1 && !jumping)
{
onground = false;
shooting = false;
jumping = true;
jumpsetup = true;
_loc1_.gotoAndStop(3);
}
lasty = _loc1_._y;
moveLayer._x = Math.round(160 - _loc1_.x);
moveLayer._y = Math.round(150 - _loc1_.y);
if(moveLayer._y < -1268)
{
moveLayer._y = -1268;
}
bg._x = moveLayer._x / 2 - 160;
bg._y = moveLayer._y / 2 - 120;
if(Key.isDown(32) && !shooting)
{
shooting = true;
jumping = false;
jumpsetup = false;
_loc1_.gotoAndStop(4);
}
if(_loc1_.y > 1200)
{
delete _root.moveLayer.hero.onEnterFrame;
_root.moveLayer.hero.gotoAndStop("dead");
}
_loc1_._x = Math.floor(_loc1_.x);
_loc1_._y = Math.floor(_loc1_.y);
};
moveBullet = function()
{
var _loc1_ = this;
_loc1_._x += _loc1_.dx;
if(_loc1_._x < moveLayer.hero._x - 500 || _loc1_._x > moveLayer.hero._x + 500)
{
_loc1_.removeMovieClip();
}
};
createBullet = function()
{
var _loc1_ = moveLayer.hero._xscale / 80;
nm = "bul0";
moveLayer.attachMovie("bullet",nm,100);
moveLayer[nm]._x = moveLayer.hero._x + 35 * _loc1_;
moveLayer[nm]._y = moveLayer.hero._y - 25;
moveLayer[nm]._xscale = _loc1_ * 100;
moveLayer[nm].dx = 20 * _loc1_;
moveLayer[nm].onEnterFrame = moveBullet;
};
moveSplat = function()
{
var _loc1_ = this;
_loc1_._x += _loc1_.dx;
if(_loc1_._x < moveLayer.hero._x - 300 || _loc1_._x > moveLayer.hero._x + 300)
{
_loc1_.removeMovieClip();
}
if(_loc1_.hitTest(moveLayer.hero))
{
moveLayer.hero.dx = _loc1_.dx * 5;
moveLayer.hero.dy = -10;
gotshot.start();
_root.stats.health.nextFrame();
_loc1_.removeMovieClip();
}
};
numsplats = 0;
createSplat = function()
{
var _loc2_ = this;
var _loc1_ = _loc2_._xscale / 80;
nm = "splat" add numsplats;
moveLayer.attachMovie("splatBullet",nm,numsplats + 200);
moveLayer[nm]._x = _loc2_._x + 35 * _loc1_;
moveLayer[nm]._y = _loc2_._y - 25;
moveLayer[nm]._xscale = _loc1_ * 100;
moveLayer[nm].dx = 10 * _loc1_;
moveLayer[nm].onEnterFrame = moveSplat;
numsplats++;
numsplats %= 20;
};
simpleMove = function()
{
var _loc1_ = this;
if(_loc1_.x == undefined)
{
_loc1_.x = _loc1_._x;
_loc1_.y = _loc1_._y;
}
_loc1_.x += _loc1_.dx;
_loc1_.y += _loc1_.dy;
if(_loc1_.x < _loc1_.x1)
{
_loc1_.x = _loc1_.x1;
_loc1_.dx *= -1;
}
else if(_loc1_.x > _loc1_.x2)
{
_loc1_.x = _loc1_.x2;
_loc1_.dx *= -1;
}
if(_loc1_.dx > 0)
{
_loc1_._xscale = 80;
}
else if(_loc1_.dx < 0)
{
_loc1_._xscale = -80;
}
_loc1_._x = Math.floor(_loc1_.x);
_loc1_._y = Math.floor(_loc1_.y);
if(_loc1_.hitTest(moveLayer.bul0))
{
_loc1_.gotoAndStop(2);
_loc1_.onEnterFrame = null;
moveLayer.bul0.removeMovieClip();
}
if(random(50) == 0)
{
_loc1_.gotoAndStop(3);
}
};
intro.playButton.onRelease = function()
{
intro._visible = false;
moveLayer.hero.onEnterFrame = moveme;
};